<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>查询所有</title>
    <style>
        table {
            margin: auto;
        }

        #add {
            margin-left: 150px;
        }
    </style>
</head>
<body>

<div class="tb">
    <h1>${user.username}，欢迎您！</h1>
    <input type="button" value="添加" id="add">
    <hr>
    <table border="1" cellspacing="0" width="80%">
        <tr>
            <th>序号</th>
            <th>品牌名称</th>
            <th>企业名称</th>
            <th>排序</th>
            <th>品牌介绍</th>
            <th>状态</th>
            <th>操作</th>
        </tr>

        <c:forEach items="${brands}" var="brand" varStatus="status">
            <tr style="text-align: center">
                <td>${status.count}</td>
                <td>${brand.brandName}</td>
                <td>${brand.companyName}</td>
                <td>${brand.ordered}</td>
                <td>${brand.description}</td>
                <c:if test="${brand.status == 1}">
                    <td>启用</td>
                </c:if>
                <c:if test="${brand.status != 1}">
                    <td>禁用</td>
                </c:if>
                <td>
                    <a href="/brand-demo/selectByIdServlet?id=${brand.id}">修改</a>
                    <a href="/brand-demo/deleteByIdServlet?id=${brand.id}">删除</a>
                </td>
            </tr>
        </c:forEach>
    </table>
</div>

<script>
    document.getElementById("add").onclick = function () {
        location.href = "/brand-demo/addBrand.jsp";
    }
</script>
</body>
</html>
